function mdl = slcisogauss(mu, sigma)
%SLCISOGAUSS Constructs Gaussian model(s) with isotropic covariance
%
% [ Syntax ]
%   - mdl = slcisogauss()
%   - mdl = slcisogauss(mu, sigma)
%
% [ Arguments ]
%   - mu:       the mean vector(s)
%   - sigma:    the variance(s)
%   - mdl:      the constructed model object
%
% [ Description ]
%   - mdl = slcisogauss() constructs an empty Gaussian model.
%
%   - mdl = slcisogauss(mu, sigma) constructs Gaussian model(s) with
%     isotropic covariance with both mean vector(s) and variance(s)
%     given.
%
%     To construct a single model, mu should be a d x 1 mean vector,
%     while sigma should be a scalar giving the uniform variance.
%
%     You can also construct an array of K models. To this end, you 
%     should input mu as an d x K matrix, with each column giving a
%     mean vector. sigma can be specified in either of the following
%     forms:
%       - 1 x K row vector with each element giving the variance for
%         a particular model.
%       - {1 x 1 scalar} with the element in the cell giving the
%         uniform variance shared by all models.
%
% [ History ]
%   - Created by Dahua Lin, on Dec 25, 2007
%

%% main

if nargin == 0    % empty model
    
    mu = [];
    sigma = [];
    
else
    
    assert(isnumeric(mu) && ndims(mu) == 2, ...
        'sltoolbox:slcisogauss:slcisogauss:invalidarg', ...
        'mu should be a numeric matrix.');
    
    % mean vectors
    
    [d, K] = size(mu);
    
    if K > 1
        mu = slslice(mu, 1);
    end
    
    % variances
    
    if isnumeric(sigma)    % non-shared
        assert(isequal(size(sigma), [1, K]), ...
            'sltoolbox:slcisogauss:slcisogauss:invalidarg', ...
            'The size of sigma is invalid.');
        
        if K > 1
            sigma = slslice(sigma, 0)';        
        end
        
    elseif iscell(sigma) && numel(sigma) == 1  % shared
        sigma = sigma{1};
        
        assert(isnumeric(sigma) && isscalar(sigma), ...
            'sltoolbox:slcisogauss:slcisogauss:invalidarg', ...
            'The shared sigma should be a scalar in cell.');        
        
    else
        error('sltoolbox:slcisogauss:slcisogauss:invalidarg', ...
            'sigma is invalid.');
    end
    
end

% make struct

mdl = class(struct('mu', mu, 'sigma', sigma), 'slcisogauss');





    
    
    